Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

CRM-21124 fix error on cacheKey when too long #10921

Merged
merged 1 commit into from
Aug 31, 2017

Conversation

eileenmcnaughton
Copy link
Contributor

@eileenmcnaughton eileenmcnaughton commented Aug 30, 2017

Overview

Fixes a rare DB error when merging with a long criteria string, which exceeds the field length

Before

Fatal error when calling the batchMerge with a long critieria string (hard to do outside of code or api calls)

After

No fatal error

Technical Details

By passing criteria through md5() we can ensure it is no longer than 32 char


@@ -1914,7 +1914,7 @@ public static function getMergeCacheKeyString($rule_group_id, $group_id, $criter
$cacheKeyString = "merge {$contactType}";
$cacheKeyString .= $rule_group_id ? "_{$rule_group_id}" : '_0';
$cacheKeyString .= $group_id ? "_{$group_id}" : '_0';
$cacheKeyString .= !empty($criteria) ? serialize($criteria) : '_0';
$cacheKeyString .= !empty($criteria) ? md5(serialize($criteria)) : '_0';
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Probably a silly question, but from the description it looks like this key is stored in the database. When upgrading to the next version will the cache always be cleared? It would probably be harmless to have the old version of the cache key still in the database anyway, but just thought I'd check.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I think upgrades do clear these out, or you can schedule a job to intermittently clear cache tables.

This is the sort of cache that just gets regenerated if empty. I can't see any risks on there being extraneous or missing entries

Copy link
Contributor

@mickadoo mickadoo left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

looks good to me, if this is the path we're going to take maybe there are other places that are also at risk of the same problem that could be fixed.

@monishdeb
Copy link
Member

Make sense.

@monishdeb monishdeb merged commit 02ff1fd into civicrm:master Aug 31, 2017
@eileenmcnaughton eileenmcnaughton deleted the cachekey branch August 31, 2017 21:10
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

Successfully merging this pull request may close these issues.

4 participants